package com.shan;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class ArrayTest2 {
    /*
            需求：
                已知班级学生成绩为
                int[] arr ={100,50,20,90,90}
                1.找出数组最大值，并打印在控制台
                2.找出数组最小值，，并打印在控制台
                3.求总成绩，并打印在控制台
                4.计算出平均值，并打印在控制台
                5.统计出低于平均数的个数
     */
    public static void main(String[] args) {
        int[] arr1 ={100,50,20,90,90};
       int max=GetMax(arr1);
        System.out.println(max);
        System.out.println("--------");
        int min = GetMin(arr1);
        System.out.println(min);
       int sum = getSum(arr1);
        System.out.println(sum);
        int pingjun = sum/arr1.length;
        System.out.println(pingjun);
        int count = down(arr1);
        System.out.println(count);
    }
    public static  int GetMax(int[] arr){
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(arr[i]>max){
                max=arr[i];
            }
        }
        return max;
    }
    public static  int GetMin(int[] arr){
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(arr[i]<min){
                min=arr[i];
            }
        }
        return min;
    }
    public static int getSum(int[] arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }
   public static int down(int[] arr){
        int pingjin =getSum(arr)/arr.length;
        int count=0;
       for (int i = 0; i < arr.length; i++) {
           if(pingjin>arr[i]){
               count++;
           }
       }
        return count;
   }
}
